
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Medicine;
import cn.edu.scau.cmi.hombio.domain.MedicineTake;
import cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class MedicineTakeDetailServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected MedicineTakeDetailService service;

	/**
	 * Instantiates a new MedicineTakeDetailServiceTest.
	 *
	 */
	public MedicineTakeDetailServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void saveMedicineTakeDetail() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeDetail 
		MedicineTakeDetail medicinetakedetail = new cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail();
		service.saveMedicineTakeDetail(medicinetakedetail);
	}

	/**
	 * Operation Unit Test
	* Return a count of all MedicineTakeDetail entity
	* 
	 */
	@Test
	public void countMedicineTakeDetails() {
		Integer response = null;
		response = service.countMedicineTakeDetails();
		// TODO: JUnit - Add assertions to test outputs of operation: countMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findMedicineTakeDetailByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findMedicineTakeDetailByPrimaryKey 
		Integer id = 0;
		MedicineTakeDetail response = null;
		response = service.findMedicineTakeDetailByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findMedicineTakeDetailByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineTake entity
	* 
	 */
	@Test
	public void deleteMedicineTakeDetailMedicineTake() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeDetailMedicineTake 
		Integer medicinetakedetail_id = 0;
		Integer related_medicinetake_id = 0;
		MedicineTakeDetail response = null;
		response = service.deleteMedicineTakeDetailMedicineTake(medicinetakedetail_id, related_medicinetake_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeDetailMedicineTake
	}

	/**
	 * Operation Unit Test
	* Delete an existing Medicine entity
	* 
	 */
	@Test
	public void deleteMedicineTakeDetailMedicine() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeDetailMedicine 
		Integer medicinetakedetail_id_1 = 0;
		Integer related_medicine_id = 0;
		MedicineTakeDetail response = null;
		response = service.deleteMedicineTakeDetailMedicine(medicinetakedetail_id_1, related_medicine_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteMedicineTakeDetailMedicine
	}

	/**
	 * Operation Unit Test
	* Return all MedicineTakeDetail entity
	* 
	 */
	@Test
	public void findAllMedicineTakeDetails() {
		// TODO: JUnit - Populate test inputs for operation: findAllMedicineTakeDetails 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<MedicineTakeDetail> response = null;
		response = service.findAllMedicineTakeDetails(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Save an existing MedicineTake entity
	* 
	 */
	@Test
	public void saveMedicineTakeDetailMedicineTake() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeDetailMedicineTake 
		Integer id_1 = 0;
		MedicineTake related_medicinetake = new cn.edu.scau.cmi.hombio.domain.MedicineTake();
		MedicineTakeDetail response = null;
		response = service.saveMedicineTakeDetailMedicineTake(id_1, related_medicinetake);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeDetailMedicineTake
	}

	/**
	 * Operation Unit Test
	* Delete an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void deleteMedicineTakeDetail() {
		// TODO: JUnit - Populate test inputs for operation: deleteMedicineTakeDetail 
		MedicineTakeDetail medicinetakedetail_1 = new cn.edu.scau.cmi.hombio.domain.MedicineTakeDetail();
		service.deleteMedicineTakeDetail(medicinetakedetail_1);
	}

	/**
	 * Operation Unit Test
	* Load an existing MedicineTakeDetail entity
	* 
	 */
	@Test
	public void loadMedicineTakeDetails() {
		Set<MedicineTakeDetail> response = null;
		response = service.loadMedicineTakeDetails();
		// TODO: JUnit - Add assertions to test outputs of operation: loadMedicineTakeDetails
	}

	/**
	 * Operation Unit Test
	* Save an existing Medicine entity
	* 
	 */
	@Test
	public void saveMedicineTakeDetailMedicine() {
		// TODO: JUnit - Populate test inputs for operation: saveMedicineTakeDetailMedicine 
		Integer id_2 = 0;
		Medicine related_medicine = new cn.edu.scau.cmi.hombio.domain.Medicine();
		MedicineTakeDetail response = null;
		response = service.saveMedicineTakeDetailMedicine(id_2, related_medicine);
		// TODO: JUnit - Add assertions to test outputs of operation: saveMedicineTakeDetailMedicine
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
